package org.abacus.hibernate.mandarinduck;

import org.abacus.hibernate.model.HibernateModel;
import org.junit.Test;

public class HibernateSessionFilterTest {
	static {
		HibernateSessionProvider.addTags();
	}
	SessionFilter filter = HibernateSessionFilter.getInstance();
	TransactionStrategy txs = HibernateTransactionStrategy.getInstance();

	@Test
	public void testStart() {
		try {
			filter.open();
			txs.begin();
			HibernateModel m = new HibernateModel();
			m.setCode("reason");
			HibernateSessionProvider.getCurrentSessionIn().save(m);
			m = new HibernateModel();
			m.setCode("reason");
			HibernateSessionProvider.getCurrentSessionOut().save(m);
			txs.commit();
			filter.close();
		} catch (Exception e) {
			txs.rollback();
			e.printStackTrace();
		}
	}

}
